/**
 * Created by z30 on 15-6-5.
 */


var log4js = require('log4js');
log4js.configure({
    appenders: [
        {
            type: 'console',
            category: "console"
        }, //控制台输出
        {
            type: "dateFile",
            filename: './logs/http.log',
            pattern: "yyyy-MM-dd",
            backups:14,
            alwaysIncludePattern: false,
            category: 'SDK'
        }//日期文件格式
    ],
    replaceConsole: true   //替换console.log
});
var dateFileLog = log4js.getLogger('SDK');
exports.logger = dateFileLog;
exports.use = function(app) {
    //页面请求日志,用auto的话,默认级别是WARN
    //app.use(log4js.connectLogger(dateFileLog, {level:'auto', format:':method :url'}));
    app.use(log4js.connectLogger(dateFileLog, {
        format:':req[x-forward-for] :remote-addr :method :url :user-agent :status :req[content-length] :response-time'+'ms'}));
};